package com.gujia.designpattern.cor;

import com.gujia.designpattern.cor.handler.PriceHandler;
import com.gujia.designpattern.cor.util.PriceHandlerFactory;

import java.util.Random;

/**
 * 客户，请求折扣
 */
public class Customer {


    private PriceHandler priceHandler;

    public void setPriceHandler(PriceHandler priceHandler) {
        this.priceHandler = priceHandler;
    }

    public void requestDiscount(float discount){
        priceHandler.processDiscount(discount);
    }


    public static void main(String[] args) {
        Customer customer = new Customer();
        customer.setPriceHandler(PriceHandlerFactory.createPriceHandler());
        customer.requestDiscount(new Random().nextFloat());
    }
}
